package com.trkj.property_controller;

import ch.qos.logback.core.net.SyslogOutputStream;
import com.trkj.entity.HouseEntity;
import com.trkj.entity.HouseholdEntity;
import com.trkj.service.HouseService;
import com.trkj.vo.AjaxResponse;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;
import java.util.ListResourceBundle;

@RestController
@Slf4j
@CrossOrigin
public class HouserController {
    @Resource
    private HouseService houseService;
    @PostMapping("/selectAll")
    public AjaxResponse selectAll(@RequestBody HouseEntity houseEntity,@RequestParam("currentPage")int currentPage, @RequestParam("pageSize")int pageSize) {
        log.info("{}",houseEntity);
        return AjaxResponse.success(houseService.selectAll(houseEntity,currentPage, pageSize));
    }
    @PostMapping("/selectHouse")
    public List<HouseEntity> selectHouse(){
        return houseService.selectHouse();
    }

    @PutMapping("/updateHouse")
    public Boolean updateHouse(@RequestBody HouseEntity houseEntity){
        return houseService.updateHouse(houseEntity);
    }
    @DeleteMapping("/delHouse")
    public Boolean delHouse(@RequestParam("houseId") int houseId){
        return houseService.delHouse(houseId);
    }
    @PostMapping("/insertHouse")
    public Boolean insertHouse(@RequestBody HouseEntity houseEntity){
        return houseService.insertHouse(houseEntity);
    }
    @PostMapping("/findHsNum")
    public int findHsNum(@RequestBody HouseEntity houseEntity){
        return houseService.findHsNum(houseEntity);
    }
    @PostMapping("/findHouseBiaoQian")
    public List<HouseEntity> findBiaoQian(){
        return houseService.findHouseBiaoQian();
    }
    //查询所有房屋
    @PostMapping("/HouseList")
    public AjaxResponse HouseList(){
        return AjaxResponse.success(houseService.HouseList());
    }
}
